﻿<style>
a {color:#F90}
</style>
<?php
	$ms_muc_tin = $_REQUEST['muc_t'];

	$p = new pager1;
	
	$limit = 20;
	
	$start = $p->find_start($limit);
	
	$count = mysql_num_rows(mysql_query("SELECT * FROM mau_tin_rv WHERE giay_phep = 1 AND ms_muc_tin = $ms_muc_tin"));
	
	$pages = $p->find_pages($count, $limit);
	
	mysql_query("SET character_set_results=utf8"); //lấy dữ liệu tiếng việt từ csdl
	
	$sql="SELECT *, 
				 DATE_FORMAT(ngay_dang,'%d-%m-%Y') AS ngay FROM mau_tin_rv
		  WHERE giay_phep = 1  
				AND ms_muc_tin = $ms_muc_tin 
				AND DATE_ADD(ngay_dang, INTERVAL thoi_gian_song DAY) > NOW()
		  ORDER BY vip DESC, ngay_dang DESC 
		  LIMIT ".$start.", ".$limit;

	$rs=mysql_query($sql);
	
	echo "<div style='height:50px;'><a href='index.php?noidung=dtrv' class='com fr'>Đăng tin</a></div>";
					
	echo 			"<div class='form'>
						<table width='100%' cellpadding='5' cellspacing='1'>
							<tr class='title_ds' style='font-size:13px'>
								<td>Ngày đăng</td>
								<td>Tiêu đề</td>
								<td>Nơi đăng</td>
							</tr>";		
	
	if(mysql_num_rows($rs) > 0){
		$i = 0;
		while($row = mysql_fetch_array($rs)){
			$i++;
			$ms_mt =  $row[0];
			$tieu_de = $row[3];
			$ngay_dang = $row['ngay'];
			$noi_dang = $row[6];
			$vip = $row[9];
			$so_lan_xem = $row[10];
			
			echo   "  	<tr align='center'";
				if($i % 2 == 0) echo 'style="background-color:#f0f0f0;"';
			echo ">
							<td>$ngay_dang</td>
							<td align='left'><li><a href='dang_tin_rv/update_so_lan_xem.php?ms=$ms_mt'>$tieu_de</a>($so_lan_xem lượt xem)";
			if($vip==1){
				echo "<b style='color:red'>-VIP-</b>";	
			}
			echo			"</li></td>
							<td>$noi_dang</td>
						</tr>";
		}
	}
	
	echo 				"</table></div>";
	
	$page_list = $p->page_list($_GET['page'], $pages);
	echo "<p>";
	echo "<div class='pagenavi'>".$page_list."</div>";
	echo "</p>";
?>